using System;
using System.Collections.Generic;
using System.Text;
using Emlyn.Common.Data.SqlServer.SqlDBAccess;
using Emlyn.Common.Data.DBUpdater;
using Emlyn.Common.Data.Configuration;

namespace Emlyn.Website.GeekAngel.DBUpdateRules
{
    public class DUR_CreateVersionTable: IDBUpdaterRule
    {
        #region IDBUpdaterRule Members

        public int UpgradeFromVersion()
        {
            return 0;
        }

        public int UpgradeToVersion()
        {
            return 10;
        }

        public void PerformUpgrade()
        {
            string lCreateVersionTableSQL =
                "CREATE TABLE [dbo].[tblGAVersion] " +
                "( " +
                "   [Version] [int] NOT NULL " +
                ") ";

            string lInsertVersionRecordSQL =
                "INSERT [dbo].[tblGAVersion] (Version) Values (0)";

            SimpleSQL.Execute(Config.GetConnectionString(), lCreateVersionTableSQL);

            SimpleSQL.Execute(Config.GetConnectionString(), lInsertVersionRecordSQL);
        }

        #endregion
    }
}
